#!/usr/local/bin/python

import sys, os

filename = sys.argv[1]

f = open(filename, "r")

def fmt(f):
  st = '{0:.4}'.format(f)
  return st

lines = f.readlines()

for line in lines:
  st = line
  line = st.split('\t')
  idd = line[1]
  acc = line[2].rstrip()

  if acc != "-":
    os.system("fastacmd -d refseq_protein -p T -s " + acc + " | perl -nle 'if($_ =~ /.*gi\|(.*)\|ref.*/) {print $1}'")
  else:
    print 'Empty'

f.close()

